/**
 * @filename:AdminuserServiceImpl 2022-2-27
 * @project Wonder Java前后台分离框架  1.1.0
 * Copyright(c) 2022 Wonder Co. Ltd. 
 * All right reserved. 
 */
package com.wonder.admin.service.impl;

import com.wonder.admin.domain.Adminuser;
import com.wonder.admin.vo.AdminuserVo;
import com.wonder.admin.mapper.AdminuserDao;
import com.wonder.admin.service.AdminuserService;
import com.wonder.admin.request.AdminuserRequest;
import com.wonder.common.utils.StringUtils;


import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;

/**   
 * @Description:TODO(后台用户服务实现)
 *
 * @version: 1.1.0
 * @author: Wonder
 * 
 */
@Service
public class AdminuserServiceImpl  extends ServiceImpl<AdminuserDao, Adminuser> implements AdminuserService  {

    /**
     * 验证后台用户信息
     * 
     * @param Adminuser信息
     * @return 结果
     */
    @Override
    public String validate(Adminuser adminuser,String type){
    
    
       return "";
    }
    
    /*
	 * 分页返回，自定义多表分页数据返回
	 */
	@Override 
    public IPage<AdminuserVo> selectAdminuserVoList(AdminuserRequest request, Page<AdminuserVo> page){
	    QueryWrapper<AdminuserVo> queryWrapper = new QueryWrapper<>();
	    
	    if (null != request.getUser_id()) {
	       queryWrapper.eq("a.user_id", request.getUser_id());
	      }               
             
        if (StringUtils.hasText(request.getName())) {
			    queryWrapper.eq("a.name", request.getName());
		    } 
             
        if (StringUtils.hasText(request.getUser())) {
			    queryWrapper.eq("a.user", request.getUser());
		    } 
             
	    if (null != request.getRole_id()) {
	       queryWrapper.eq("a.role_id", request.getRole_id());
	      }               
             
	    if (null != request.getStatus()) {
	       queryWrapper.eq("a.status", request.getStatus());
	      }               
             
        
		queryWrapper.orderByDesc("a.user_id");	
		IPage<AdminuserVo> selectPage = this.baseMapper.getAdminuserVoList(page, queryWrapper);

		return selectPage;
    }
    
    /**
	 * 返回VO单个数据
	 */
	public AdminuserVo getVoById(Long user_id){
	    QueryWrapper<AdminuserVo> queryWrapper=new QueryWrapper<AdminuserVo>().eq("user_id", user_id);
		return this.baseMapper.getAdminuserVoList(queryWrapper);
	}



}